#!/usr/bin/perl -w
use 5.010;

$_="Hello there, neighbor";
if(/\s(\w+),/){
	print "the word was $1\n";
}

$_="Hello there, neighbor";
if(/(\S+) (\S+), (\S+)/){
	print "words were $1 $2 $3\n";
}

my $dino="I fear that I'll be extinct after 1000 years.";
if($dino=~/(\d*) years/){
	print "That said '$1' years.\n";
}

$dino="I fear that I'll be extinct after a few million years.";
if($dino=~/(\d*) years/){
	print "That said '$1' years.\n";
}
else{
	print "Wilma doesn't have a word.\n";
}
$_="fred like brontosaurus steak.";
if(/(bronto)?saurus (steak|burger)/){
	print "Fred wants a $2\n";
}
$_="fred like brontosaurus burger.";
if(/(?:bronto)?saurus (steak|burger)/){
	print "Fred wants a $1\n";
}

$_="fred like brontosaurus burger.";
if(/(?:bronto)?saurus (?:BBQ)?(steak|burger)/){
	print "Fred wants a $1\n";
}
